package com.xcc.singletonpattern;

/**
 * @Description: Singleton
 * @Author xiechuang
 * @Date 2022/9/6
 */
public class Singleton1 {

    private static Singleton1 uniqueInstance;

    private Singleton1() {}

    // version1："延迟实例话"，多线程可能会出现多个实例
    public static Singleton1 getInstance() {
        if (uniqueInstance == null) {
            // 注意：这里会有多线程问题
            uniqueInstance = new Singleton1();
        }
        return uniqueInstance;
    }

}
